package com.astar
{
	/**
	 * 网格类，负责对节点的操作，存储
	 * */
	public class Grid
	{
		//开始节点
		private var _startNode :Node
		//结束节点
		private var _endNode :Node
		//所有节点的数组
		private var _nodes :Array;
		//将要设置网格的列数
		private var _numRow :int;
		//将要设置网格的列数
		private var _numCol :int;
		public function Grid(numRow :int,numCol :int)
		{
			this._numCol = numCol;
			this._numRow = numRow;
			_nodes = new Array();
			//初始化节点，此时节点中是没有信息的，就是一个空的节点，里面有各种属性
			for(var i:int = 0; i < _numCol; i++)
			{
				_nodes[i] = new Array();
				for(var j:int = 0; j < _numRow; j++)
				{
					_nodes[i][j] = new Node(i,j);
				}
			}
		}
		/**设置网格是否可行*/
		public function setWalkable(x :int,y :int,value :Boolean):void
		{
			(_nodes[x][y] as Node).walkable = value;
		}
		/**获取节点*/
		public function getNode(x :int, y :int):Node
		{
			return _nodes[x][y] as Node;
		}
		/**获取行数*/
		public function get numRow():int
		{
			return _numRow;
		}
		/**获取列数*/
		public function get numCol():int
		{
			return _numCol;
		}
		/**设置起点*/
		public function setStartNode(x :int,y:int):void
		{
			_startNode = _nodes[x][y] as Node;
		}
		/**设置终点*/
		public function setEndNode(x :int,y:int):void
		{
			_endNode = _nodes[x][y] as Node;
		}
		/**返回起点节点*/
		public function get startNode():Node
		{
			return _startNode;
		}
		/**返回终点节点*/
		public function get endNode():Node
		{
			return _endNode;
		}
	}
}